package edu.jd.movieplatform.info.movie;


import edu.jd.movieplatform.common.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/info/movie")
public class MovieAPI {

    @Resource
    private MovieService movieService;


    @RequestMapping("/movie-list")
    public Result movieList(MovieDto dto) {

        List<Movie> movieList = movieService.getMovieList(dto);
        return Result.success(movieList);

    }

    @RequestMapping("/moviebyid")
    public Result movieById(Integer id) {

        MovieDto dto = new MovieDto();
        dto.setMov_id(id);

        List<Movie> movieList = movieService.getMovieList(dto);
        return Result.success(movieList);

    }

    @RequestMapping("/movie-list-name")
    public Result movienameList() {

        List<Movie> movieList = movieService.getMovieNameList();
        List<String> movienameList = new ArrayList<>();
        for (int i = 0; i < movieList.size(); i++) {
            movienameList.add(movieList.get(i).getMov_name());
        }

        return Result.success(movienameList);

    }

    @RequestMapping("/movie-list/bylabel")
    public Result movieListByLabel(String label) {
        List<Movie> movieList = movieService.movieListByLabel(label);

        return Result.success(movieList);
    }

}
